package com.tn.service;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class ContextService {

	private static Class<ContextService> LOCK = ContextService.class;
	private static ApplicationContext context = null;
	private static final String[] CONTEXT_LOCATIONS = {
			"classpath:ysn_spring_config.xml",
			"classpath:ysn_po_validations_context.xml",
			"classpath:ysn_validations_context.xml" ,
			"classpath:ysn_reg_validations_context.xml"};

	private ContextService() {
		context = new ClassPathXmlApplicationContext(CONTEXT_LOCATIONS);
	}

	private static ContextService instance;

	public static ContextService getInstance() {
		if (instance == null) {
			synchronized (LOCK) {
				if (instance == null) {
					instance = new ContextService();
				}
			}
		}
		return instance;
	}

	public Object getBean(String beanName) {
		return context.getBean(beanName);
	}
}
